package com.hh.demo_ui;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.hh.listeners.OnUiDialogClickListener;
import com.hh.ui.dialog.UiAlertDialog;

public class Sample_Dialog extends Activity implements OnClickListener {


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sample_dialog);

		Button lBtnSamp1 = (Button) findViewById(R.id.SDialog_mod1);
		lBtnSamp1.setOnClickListener(this);

		Button lBtnSamp2 = (Button) findViewById(R.id.SDialog_mod2);
		lBtnSamp2.setOnClickListener(this);

		Button lBtnSamp3 = (Button) findViewById(R.id.SDialog_mod3);
		lBtnSamp3.setOnClickListener(this);
		
		Button lBtnSamp4 = (Button) findViewById(R.id.SDialog_mod4);
		lBtnSamp4.setOnClickListener(this);

	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.SDialog_mod1:

			UiAlertDialog lAlertSingle=new UiAlertDialog(this);
			// set the title
			lAlertSingle.setUiTitle("Simple Test");
			// set the message
			lAlertSingle.setUiMessage("Code incorrect");
			//
			lAlertSingle.setUiNegativeButton("OK", new OnUiDialogClickListener(){
				@Override
				public void onClick(View v) {
					super.onClick(v);
					Toast.makeText(Sample_Dialog.this, "Cancel is clicked", Toast.LENGTH_SHORT).show();
				}
			});
			lAlertSingle.show();
			break;
		case R.id.SDialog_mod2:
			
			UiAlertDialog lAlertDouble=new UiAlertDialog(this);
			// set the title
			lAlertDouble.setUiTitle("Confirm exit");
			// set the message
			lAlertDouble.setUiMessage("Do you really want to exit ?");
			
			lAlertDouble.setUiNegativeButton("Cancel", new OnUiDialogClickListener() {		
				@Override
				public void onClick(View v) {
					super.onClick(v);
					Toast.makeText(Sample_Dialog.this, "Cancel is clicked", Toast.LENGTH_SHORT).show();
				}
			});
			lAlertDouble.setUiPositiveButton("Validate", new OnUiDialogClickListener() {		
				@Override
				public void onClick(View v) {
					super.onClick(v);
					Toast.makeText(Sample_Dialog.this, "Validate is clicked", Toast.LENGTH_SHORT).show();
				}
			});
			
			lAlertDouble.show();
			break;

		case R.id.SDialog_mod3:

			
			UiAlertDialog lAlertThird=new UiAlertDialog(this);
			// set the title
			lAlertThird.setUiTitle("Confirm exit");
			// set the message
			lAlertThird.setUiMessage("Do you really want to exit ?");
			
			lAlertThird.setUiNegativeButton("Cancel", new OnUiDialogClickListener() {		
				@Override
				public void onClick(View v) {
					super.onClick(v);
					Toast.makeText(Sample_Dialog.this, "Cancel is clicked", Toast.LENGTH_SHORT).show();
				}
			});
			lAlertThird.setUiPositiveButton("Validate", new OnUiDialogClickListener() {		
				@Override
				public void onClick(View v) {
					super.onClick(v);
					Toast.makeText(Sample_Dialog.this, "Validate is clicked", Toast.LENGTH_SHORT).show();
				}
			});
			lAlertThird.setUiNeutralButton("Config", new OnUiDialogClickListener() {		
				@Override
				public void onClick(View v) {
					super.onClick(v);
					Toast.makeText(Sample_Dialog.this, "Config is clicked", Toast.LENGTH_SHORT).show();
				}
			});
			
			lAlertThird.show();	
			break;
		case R.id.SDialog_mod4:

			UiAlertDialog lAlertCustomize=new UiAlertDialog(this);
			// set the title
			lAlertCustomize.setUiTitle("Customize dialog");
			// set the message
			lAlertCustomize.setUiMessage("Code incorrect");
			//
			lAlertCustomize.setUiNegativeButton("OK", new OnUiDialogClickListener(){
				@Override
				public void onClick(View v) {
					super.onClick(v);
					Toast.makeText(Sample_Dialog.this, "Cancel is clicked", Toast.LENGTH_SHORT).show();
				}
			});
			
			//Change title color 
			lAlertCustomize.setUiTitleColor(Color.RED);
			// Change Title text size
			lAlertCustomize.setUiTitleTextSize(22);
			// Add icon 
			lAlertCustomize.setUiIcon(R.drawable.ic_action_info);
			// Change background
			lAlertCustomize.setUiBackgroundColor(Color.YELLOW);
			// Change separator color 
			lAlertCustomize.setUiBackgroundTitleSeparator(Color.BLUE);	
			// Change backround button
			lAlertCustomize.setUiBackgroundButton(Color.GREEN);
			//to close dialog when clicking outside
			lAlertCustomize.setCanceledOnTouchOutside(true);
			
			lAlertCustomize.show();
			break;
		default:
			break;
		}
	}

}
